/*
 *  switchboard.h Create and manage switchboard sessions
 *  Copyright (c) 2005 Derek Ingrouville (dergro@users.sourceforge.net)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef _SWITCHBOARD_H
#define _SWITCHBOARD_H

typedef struct _MsnSwitchboard MsnSwitchboard;

#include "session.h"

#define MSG_MAX_LEN 1664

typedef void (*MsnSboardCB)(MsnSwitchboard *sboard, gpointer data);

typedef enum _MsnSwitchboardType
{
    SWITCHBOARD_CHAT_EXISTING,	/* Someone else started SB session */
	SWITCHBOARD_CHAT_NEW,		/* We started SB session */
    SWITCHBOARD_FILE,			/* File Transfer */
	SWITCHBOARD_INVALID			/* Invalid */
} MsnSwitchboardType;

struct _MsnSwitchboard
{
    MsnConnection *conn;
    MsnSession *session;
    MsnSwitchboardType type;
    char *authstr;		/* Needed to auth with switchboard server */
    unsigned int id;
 
    MsnSboardCB connect_cb;	/* Called when connection is established */

    GList *participants;	/* Contacts Participating */
    GQueue *send_queue;		/* buffer of data to send */

    gboolean connected;		/* connected flag */
};

MsnSwitchboard *msn_switchboard_new (MsnSession *session,
                                     unsigned int id,
                                     MsnSwitchboardType type);

void msn_switchboard_free (MsnSwitchboard *sboard);

int msn_switchboard_join_session (MsnSwitchboard *sboard,
                                  const char *addr, 
                                  int port,
                                  const char *authstr);

int msn_switchboard_create_session (MsnSwitchboard *sboard,
                                    const char *addr, 
                                    int port,
                                    const char *authstr);

void msn_switchboard_disconnect (MsnSwitchboard *sboard);

void msn_switchboard_set_connect_cb (MsnSwitchboard *sboard,
                                     MsnSboardCB connect_cb);

int msn_switchboard_invite_user (MsnSwitchboard *sboard, const char *passport);

int msn_switchboard_send_message (MsnSwitchboard *sboard, char *buffer);

#endif /* _SWITCHBOARD_H */
